unit uSBD_Crypto_StreamCipher;
{
Copyright 2009 Sean B. Durkin

This file is part of SBD Crypto Library.
SBD Crypto Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

SBD Crypto Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the Lesser GNU General Public License
along with SBD Crypto Library.  If not, see <http://www.gnu.org/licenses/>.
}
interface
uses Classes;
type

TAlgorithmicFeature = (  // Flags which describe hashes, ciphers and chain modes.
  afStar,  // A preferred system. Displayed with a star next to the name in the designer.
  afCryptographicallyWeak, // The system is not known to be cryptographically strong.
   // This flag is mutually exclusive with afStar.
  afNotImplementedYet,  // The algorithm has not yet been implemented,
    // but it will be displayed as an option in the object inspector
    // as an indication of future direction.
  afForTestOnly,   // For test purposes only. Do not use in a production system.
  afForRunTimeOnly,   // The selection will not be displayed as an option in the object inspector.
  af8BitMode,         // Only applicable to chain modes. Indicates that the
                      //  feed-back is byte oriented, as opposed to block oriented.
  afEncumberedByPatent,     // Indicates that deployment of a binary using this
                            // algorithm may be constrained or encumbered by a Patent.
  afEncumberedByCopyRight,  // Indicates that the deployment of the source code
    // or a bundled library binary may be constrained or encumbered by Copyright issues,
    // other than the copyright being a form of Open Source Software (OSS).
    // This flag is mutually exclusive with afOpenSourceSoftware.
  afOpenSourceSoftware, // Indicates that the source code for this algorithm
    // is covered by an OSS license.
  afCommercial); // Indicates that the deployment of either the source code
    // or the compiled binary is covered by a commercial licence.
    // For this flag to be set, afEncumberedByCopyRight must also be set.
    // Mutually exclusive with afOpenSourceSoftware.

TAlgorithmicFeatureSet = set of TAlgorithmicFeature;

ICryptoGraphicAlgorithm = interface
  ['{0562074A-4D94-4721-BC4A-65E48372A7E7}']
    function  DisplayName: string;
    function  ProgId: string;
    function  Features: TAlgorithmicFeatureSet;
  end;


TSymetricKey = class
  public
    constructor LoadFromStream( Stream: TStream);   virtual; abstract;
    procedure   SaveToStream( Stream: TStream);     virtual; abstract;
  end;


IStreamEncryptor = interface
  ['{4DC93CFC-AD4C-4D2D-9087-296CCC591995}']
    procedure Encrypt( const Plaintext: TStream);
    procedure End_Encrypt;
    procedure Reset;
  end;

IStreamDecryptor = interface
  ['{481C71F0-BBB2-4021-93F3-48A5C21F8184}']
    procedure Decrypt( const Ciphertext: TStream);
    procedure End_Decrypt;
    procedure Reset;
  end;

IStreamCipher = interface( ICryptoGraphicAlgorithm)
  ['{E2F61BDB-42A3-4A9B-A02C-FA710B23F660}']
    function  GenerateKey( Seed: TStream): TSymetricKey;
    function  SeedByteSize: integer; // Size that the input of the GenerateKey must be.
    function  Parameterize( const Params: IInterface): IStreamCipher;

    function  Start_Encrypt( Key: TSymetricKey; CipherText: TStream): IStreamEncryptor;
    function  Start_Decrypt( Key: TSymetricKey; PlainText : TStream): IStreamDecryptor;

    function  Max_EncryptPlainText_FragmentSize : integer;
    function  Max_DecryptCipherText_FragmentSize: integer;
  end;





implementation

end.
